<%- url ||= resource_url_proxy.url_for({ action: 'index' }.merge(
  q: search_filter_params[:q]&.except(resource_handler.search_field_name))
) -%>

<%= search_form_for @query, url: resource_url_proxy.url_for(action: "index"), id: "resource_search", class: 'search_form' do |f| %>
  <div class="search_field">
    <button type="submit">
      <%= render_icon('search') %>
    </button>
    <%= f.search_field resource_handler.search_field_name,
      value: params.dig(:q, resource_handler.search_field_name),
      class: 'search_input_field',
      placeholder: Alchemy.t(:search) %>
    <%= link_to render_icon(:times, size: '1x'), url,
        class: 'search_field_clear',
        id: 'search_field_clear',
        title: Alchemy.t(:click_to_show_all),
        style: search_filter_params.fetch(:q, {}).fetch(resource_handler.search_field_name, '').present? ? 'visibility: visible' : 'visibility: hidden' %>

    <% if search_filter_params.fetch(:tagged_with, nil) %>
      <%= hidden_field_tag :tagged_with, search_filter_params.fetch(:tagged_with), id: nil %>
    <% end %>

    <% local_assigns.fetch(:additional_params, []).each do |additional_param| %>
      <%= hidden_field_tag additional_param, search_filter_params[additional_param], id: nil %>
    <% end %>
  </div>
<% end %>
